package priv.stones.io.Scanner.file;

import java.io.*;

/**
 * @Author: Stones
 * @Description:
 * @Date: 2017/10/31 16:10
 */
public class CopyDemo {

    public static void main(String[] args) throws IOException {
        System.getProperties().list(System.out);
        String source = "E:\\hello\\test.psd";
        String target = "E:\\hello\\test1.psd";
        File sourceFile = new File(source);
        File targetFile = new File((target));
        long start= System.currentTimeMillis();
        InputStream inputStream = new FileInputStream(sourceFile);
        OutputStream outputStream = new FileOutputStream(targetFile);
        Copy(inputStream, outputStream);
        inputStream.close();
        outputStream.close();
        long end = System.currentTimeMillis();
        System.out.println("time=" + (end - start));
    }

    public static void Copy(InputStream is, OutputStream os) throws IOException {
        int temp;
        byte[] data = new byte[2048];
        while ((temp = is.read(data)) != -1) {
            System.out.println(temp);
            os.write(data,0,temp);
        }
    }

}
